﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;

namespace ZOIL.DataModel
{
    /// <summary>
    /// Base Class for ViewModel that supports PropertyChange Notification and Command Binding
    /// </summary>
    public class BaseViewModel : BasePropertyChange, IViewModel
    {
        #region properties

        #region View

        /// <summary>
        /// The <see cref="View" /> property's name.
        /// </summary>
        public const string ViewPropertyName = "View";

        private FrameworkElement _view = null;

        /// <summary>
        /// Sets and gets the View property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public virtual FrameworkElement View
        {
            get
            {
                return _view;
            }

            set
            {
                if (_view == value)
                {
                    return;
                }

                RaisePropertyChanging(ViewPropertyName);
                _view = value;
                RaisePropertyChanged(ViewPropertyName);
            }
        }

        #endregion

        #region Model

        /// <summary>
        /// The <see cref="Model" /> property's name.
        /// </summary>
        public const string ModelPropertyName = "Model";

        /// <summary>
        /// This is the model which holds all logic and properties.
        /// </summary>
        private object _model = null;

        /// <summary>
        /// Sets and gets the Model property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public virtual object Model
        {
            get
            {
                return _model;
            }

            set
            {
                if (_model == value)
                {
                    return;
                }

                RaisePropertyChanging(ModelPropertyName);
                _model = value;
                RaisePropertyChanged(ModelPropertyName);
            }
        }

        #endregion

        #endregion

        #region ctor

        public BaseViewModel()
        {
        }

        #endregion
    }
}